/**
*  \file swidft.h
*
*  \brief Software ID from time.
*
*  \authors Michael J. Hohmann  <michael.hohmann@linde-mh.de>
*
*/
#ifndef SWIDFT_H_INCLUDED
#define SWIDFT_H_INCLUDED

/*================================================[ public includes  ]================================================*/
#include "stm32f10x.h"
#include "global.h"
#include "var_tbl.h"

/*================================================[ public defines   ]================================================*/

/*================================================[ public datatypes ]================================================*/

/*================================================[ public variables ]================================================*/

/*================================================[ inline functions ]================================================*/

/*================================================[ public functions ]================================================*/
/**
*  Software ID from time.
*
*  Convert the time to an obfuscated string aka. Software-ID.
*
*  \param time Time in seconds since 1970-01-01 00:00:00
*  \param str  Pointer to a string with the length of at least 13 characters.
*
*  \return RC_SUCCESS if successful.
*/
typedef enum
{
   RC_SUCCESS                    =  0,  /**< Function was successfully completed.                         */
   RC_ERROR                      = -1,  /**< Non specific error.                                          */
   RC_ERROR_NULL                 = -2,  /**< A pointer was NULL when a non-NULL pointer was expected.     */
   RC_ERROR_ZERO                 = -3,  /**< A value was zero when no zero can be accepted.               */
   RC_ERROR_MEMORY               = -4,  /**< Out of memory.                                               */
   RC_ERROR_RANGE                = -5,  /**< A value was out of Range.                                    */
   RC_ERROR_OVERRUN              = -6,  /**< A value was too big.                                         */
   RC_ERROR_UNDERRUN             = -7,  /**< A value was too small                                        */
   RC_ERROR_BUFFER_FULL          = -8,  /**< A buffer was full.                                           */
   RC_ERROR_BUFFER_EMTPY         = -9,  /**< A buffer was empty.                                          */
   RC_ERROR_BUSY                 = -10, /**< A resource was busy.                                         */
   RC_ERROR_TIME_OUT             = -11, /**< Something take too much time.                                */
   RC_ERROR_OPEN                 = -12, /**< A device can't be opened.                                    */
   RC_ERROR_CHECKSUM             = -13, /**< Wrong checksum.                                              */
   RC_ERROR_READ_ONLY            = -14, /**< Object is read only.                                         */
   RC_ERROR_WRITE_ONLY           = -15, /**< Object is write only.                                        */
   RC_ERROR_INVALID              = -16, /**< Object is invalid.                                           */
   RC_ERROR_READ_FAILS           = -17, /**< Could not read from object.                                  */
   RC_ERROR_WRITE_FAILS          = -18, /**< Could not write to the object.                               */
   RC_ERROR_NOT_MATCH            = -19, /**< Could not write to the object.                               */
   RC_ERROR_FILE_ACCESS          = -20, /**< Access to the file device fails.                             */
   RC_ERROR_FILE_SIZE_UNDERRUN   = -21, /**< File device minimum data size not reached.                   */
   RC_ERROR_VERIFY               = -22
}RC;

struct bis
{
   U32 bis_version; 		/**< Version Number of BIS  		*/
   void const *checksum_start; 		/**< Start address of application 	*/
   U32 checksum_len; 		/**< Size of application in words   */
   U32 checksum_value; 		/**< Checksum value 				*/
   U32 build_time;			/**< Build ID of application		*/
   U32 diag_version; 		/**< Diagnostic version				*/
   U32 reserved; 			/**< reserved 						*/
   U32 bis_checksum;		/**< checksum of this header		*/
};


typedef char CH;
RC swidft_software_id_from_time(U32 time, CH str[]  );
U32 mcu_get_build_time_app(void);

/*====================================================================================================================*/

#endif

/***********************************************************************************************************************
*                             Copyright 2017 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/
